﻿using B.Z.BasicData.API.Read.Application.Excused;
using B.Z.BasicData.API.Read.DTO.ExcuseDtos;
using B.Z.BasicData.Domain.Entity.Authorize;
using B.Z.BasicData.Domain.Entity.Excused;
using B.Z.BasicData.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.Z.BasicData.API.Read.Controllers
{
    /// <summary>
    /// 控制器-读（请假管理）
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class ExcusedController : ControllerBase
    {
        private readonly IMediator mediator;

        public ExcusedController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 部门下拉框
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<T_Department>>> GetDepartList() 
        {
            DepartmentQueryCommand command = new DepartmentQueryCommand();

            return mediator.Send(command);
        }
        /// <summary>
        /// 请假类型
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<T_ExcusedType>>> GetTypeList()
        {
            ExcusedTypeQueryCommand command = new ExcusedTypeQueryCommand();
            return mediator.Send(command);
        }
        /// <summary>
        /// 获取部门领导名称
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<T_User>> GetLeder(int id,string idList)
        {
            GetLeaderCommand command = new GetLeaderCommand();
            command.DepartId = id;
            command.RidList = idList;
            return mediator.Send(command);
        }
        /// <summary>
        /// 获取请假列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<APIPaging<ExcusedDto>>> GetExcused([FromQuery] ExcusedQueryCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 获取请假报表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<APIPaging<ExcusedFormDtos>>> GetExcusedForm([FromQuery] ExcuseFormQueryCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 获取员工每个月请假明细
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<ExcusedDto>>> GetExcusedDetail([FromQuery] ExcuseDetailQueryCommand command)
        {
            return mediator.Send(command);
        }
    }
}
